

<?php

include '../../../constant.php';
require_once LIBRARIES_ENTITIES_DATABASE;
require_once LIBRARIES_ENTITIES_KEYS;


$db = new Database();
try {
    $key = new Keys();
    $keyList = $key->getList($db);

    if (count($keyList) > 0) {
        foreach ($keyList as $key) {
            $json['id'] = $key->getID();
            $json['name'] = $key->getName();
            $data[] = $json;
        }
        echo json_encode($data);
    } else {
        echo 'nothing to show';
    }
} catch (PDOException $exc) {
    echo "getKeyList error: " . $exc->getMessage();
}
?>